﻿using System;

namespace IQIGame.Onigao.GamePlay
{
    public struct EquipFilter : IEquatable<EquipFilter>
    {
        public int locationType; // 定位
        public int quality; // 稀有度
        public int wearState; // 穿戴状态(0-无,1穿戴，2未穿戴)

        public EquipFilter(int locationType, int quality, int wearState) : this()
        {
            this.Sync(locationType, quality, wearState);
        }

        public EquipFilter Sync(int locationType, int quality, int wearState)
        {
            this.locationType = locationType;
            this.quality = quality;
            this.wearState = wearState;
            return this;
        }

        public EquipFilter Sync(EquipFilter other)
        {
            return this.Sync(other.locationType, other.quality, other.wearState);
        }

        public EquipFilter Sync(UIEquipLocationType locationType, int quality, int wearState)
        {
            return this.Sync((int)locationType, quality, wearState);
        }

        public override bool Equals(object obj)
        {
            if (obj is EquipFilter other)
                return Equals(other);
            return false;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(locationType, quality, wearState);
        }


        public bool Equals(EquipFilter other)
        {
            return this.locationType == other.locationType && this.quality == other.quality && this.wearState == other.wearState;
        }

        static public readonly EquipFilter Default = new EquipFilter(0, 0, 0);

        public static bool operator ==(EquipFilter lhs, EquipFilter rhs) { return lhs.Equals(rhs); }
        public static bool operator !=(EquipFilter lhs, EquipFilter rhs) { return !(lhs == rhs); }
    }
}
